<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>String.prototype.matchAll</title>
</head>
<body>
<script>
  str = `
    <nav>
    <ul>
        <li>
            <a href="#">学习</a>
            <p>日期: 2023-1-1</p>
        </li>
        <li>
            <a href="#">游戏</a>
            <p>日期: 2023-10-10</p>
        </li>
    </ul>
</nav>`
  // dot -- . (dot ==> .  元字符  除换行符以外的任意单个字符)
  // 正则
  const reg = /<li>.*?<a href="#">(.*?)<\/a>.*?<p>(.*?)<\/p>/gs  // g -- 全局匹配、s -- 换行
  const result =str.matchAll(reg)
  for (let item of result) {
    console.log({name:item[1], time:item[2]})
  }
</script>
</body>
</html>